home *** CD-ROM | disk | FTP | other *** search
- Path: netnews.whoi.edu!NewsWatcher!user
- From: davef@mbl.edu (Dave Fernandes)
- Newsgroups: comp.lang.c++
- Subject: Re: [Q] how declare a Template class as a friend
- Date: Mon, 11 Mar 1996 11:04:16 -0500
- Organization: Marine Biological Laboratory
- Message-ID: <davef-1103961104160001@128.128.173.90>
- References: <Dnx660.1Ex@news.uwindsor.ca>
- NNTP-Posting-Host: 128.128.173.90
-
- In article <Dnx660.1Ex@news.uwindsor.ca>, saed@engn.uwindsor.ca wrote:
-
- > Hi all,
- >
- > --- How do you declare a template class to be a friend of
- > another non-template class?
- >
- > template <class T> class A {}; // the template class A<T's>
- > class B { friend class A }; // won't do it, A is not a class
- > template <class V> class B { friend class A<V> }; // B<V's> are
- not wanted
-
- What if you declare your template class A as a subclass of some other
- abstract class C, and have C be a friend of B?
-
- class C {};
- template <class T> class A : public C {};
- class B {friend class C};
-
- I'm not sure, but I think this should work.
-
- --
- Dave Fernandes
- Postdoctoral Research Associate
- The Ecosystems Center
- Marine Biological Laboratory
-